<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/css/public.css" media="all">

    <style>
        .table-row-bar{
            padding: 0px 5px;
            cursor: pointer;
        }
    </style>
</head>
<body>
<div id="container" class="layuimini-container">
    <div class="layuimini-main">
        <h2><b>申请单列表</b></h2>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>

<!-- Vue 表达式与Layui模板表达式冲突，需放在Vue Scope 外边 -->
<script type="text/html" id="operTpl">
    <a class="table-row-bar" lay-event="dealApply" style="color: #1890FF;">处理</a>
</script>

<script type="text/html" id="applyTypeTpl">
    {{# if(d.reqType == '1000'){ }}
        <span style="color: #1890FF;">提币</span>
    {{# } else { }}
        <span style="color: #5FB878;">兑换</span>
    {{#  } }}
</script>

<script src="/wpui-admin/wp-ewallet-admin/static/js/jquery-3.4.1.min.js"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/lib/layui/layui.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/module/index/config.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/js/vue.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/js/vue-i18n.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp-i18n.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp-project.js" charset="utf-8"></script>

<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        var vm = new Vue({
            el: '#container',
            i18n: wp.i18n(),
            data: {
                name:'张三'
            },
            mounted:function(){
                this.init();
                this.grid();
            },
            methods: {
                init:function(){

                },
                grid:function(){
                    var that = this;
                    table.render({
                        elem: '#currentTableId',
                        url: wp.url('/wp/ewallet/wallet/reqOrder/pending'),
                        headers:wp.getAjaxHeaders(),
                        parseData: wp.parseGridData,
                        cols: [[
                            {field: 'reqOrderId', title: '申请单ID'},
                            {field: 'reqType', title: '申请类型', templet: '#applyTypeTpl'},
                            {field: 'userTel', title: '申请用户'},
                            {field: 'createDate', title: '申请时间'},
                            {title: '操作', templet: '#operTpl', fixed: "right", align: "center"}
                        ]],
                        limits: wp.config.pageList,
                        limit: wp.config.pageSize,
                        page: true
                    });

                    table.on('tool(currentTableFilter)', function (obj) {
                        var data = obj.data;
                        if (obj.event === 'dealApply') {
                            //layer.alert('编辑行：<br>' + JSON.stringify(data));
                            that.deal(data);
                        }
                    });
                },
                reloadGrid:function(){
                    //执行搜索重载
                    table.reload('currentTableId',{
                        //page: {curr: 1}
                    });
                },
                deal:function(data){
                    //alert(JSON.stringify(data))
                    var self = this;
                    var url = wp.resUrl('/wpui-admin/wp-ewallet-admin/module/wallet/wallet-apply-money.html');
                    var title = '提币申请';
                    // Demo暂用中文，实现时替换成类型码字段和值
                    if(data.reqType == '2000'){
                        url = wp.resUrl('/wpui-admin/wp-ewallet-admin/module/wallet/wallet-apply-redeem.html');
                        var title = '兑换申请';
                    }

                    // 添加到tab
                    var iframeWindow = wp.addTab(url,title);
                    iframeWindow.walletApplyVm = self;
                    iframeWindow.data = data;
                    // 窗口关闭方法
                    iframeWindow.close = function(){
                        wp.closeTab(iframeWindow.tabId);
                    }
                    iframeWindow.onLoadFinish = function(vm){

                    }
                }
            }
        });
    });
</script>
<script>

</script>

</body>
</html>